define([
  'jquery',
  'underscore',
  'views/View',
  'views/upload/UploadView',
  'hbs!template/upload/upload-photo-preview'
], function($, _, View, UploadView, template){
  var UploadPreview = UploadView.extend({
    events: {
      "click input[name=selection]":  "selection"
    },
    
    initialize: function(options){
      UploadView.prototype.initialize(options);
      this.template = template;
      this.data = options.data;
      if(this.data) {
        this.file = this.data.file;
      }
    },
    
    render: function() {
      $(this.el).html(this.template(this.model.toJSON()));
      return this;
    },

    selection: function() {
      var selected = this.model.get('selected');
      this.model.set({selected: !selected});

      this.render();
    },

    isSelected: function() {
      return this.model.get('selected');
    }
  });

  return UploadPreview;
});